package com.qk.mapper;

import com.qk.dto.ActivityDto;
import com.qk.entity.Activity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ActivityMapper {
    /**
     * 1. 活动列表查询,根据渠道来源channel ,活动类行型type,活动状态status,动态查询
     */

    List<Activity> list(ActivityDto activityDto);

    /**
     * 2. 活动删除
     * @param id
     */
    @Delete("delete from activity where id =#{id}")
    void delete(Integer id);
    /**
     * 3. 活动添加
     * @param activity,id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time)
     */

    @Insert("insert into activity(id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time) values(#{id},#{channel},#{name},#{startTime},#{endTime},#{description},#{type},#{discount},#{voucher},#{createTime},#{updateTime})")
    void insert(Activity activity);

    /**
     *.4.根据id查询
     */
    @Select("select id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time from activity where id = #{id}")
    Activity getById(Integer id);

    /**
     *
     * 5.更新activity
     */
    @Update("update activity set channel = #{channel}, name = #{name}, start_time = #{startTime}, end_time = #{endTime}, description = #{description}, type = #{type}, discount = #{discount}, voucher = #{voucher}, update_time = #{updateTime} where id = #{id}")
    void update(Activity activity);
    /**
     *
     * 6.根据类型查询
     */
    @Select("select id, channel, name, start_time, end_time, description, type, discount, voucher, create_time, update_time from activity where type = #{type}")
    List<Activity> listType(Integer  type);


}
